﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EDiamondModel;
public partial class Admin_HinhThucThanhToanThem : System.Web.UI.Page
{
    EDiamondEntities1 db = new EDiamondEntities1();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Thêm_Click(object sender, EventArgs e)
    {
        string ten = txtTen.Text.Trim();
        if (txtTen.Text == "")
            return;

        int d = db.HinhThucVanChuyens.Count(p => p.Ten == ten);
        if (d == 0) //Thêm
        {
            HinhThucVanChuyen nsx = new HinhThucVanChuyen();
            nsx.Ten = txtTen.Text.Trim();
            nsx.KyHieu = Thuvien.BoDauTiengViet(ten);

            db.HinhThucVanChuyens.AddObject(nsx);
            db.SaveChanges();
            lblThongBao.Text = "Thêm thành công!";
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirectMe", "alert('Tên đã có rồi!');", true);
        }
    }
}